package com.xyw.his00.config;

import com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties;
import org.apache.catalina.filters.CorsFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;

import java.util.ArrayList;
import java.util.Collections;

//@Configuration
public class MyFilterConfig {
  //  @Bean//注册跨域请求拦截器
    public CorsFilter corsFilter() {
        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
        CorsConfiguration config = new CorsConfiguration();
     config.setAllowedHeaders(Collections.singletonList("*"));

        config.setAllowCredentials(true);
        config.setMaxAge(1800L);
        config.addAllowedOrigin("*");
        source.registerCorsConfiguration("/**", config);
        return new CorsFilter();
    }
}
